package ru.st.selenium.applogic1;

import ru.st.selenium.applogic.FilmHelper;
import java.util.List;
import ru.st.selenium.model.Film;


public class FilmHelper1 extends DriverBasedHelper implements FilmHelper{


public FilmHelper1(ApplicationManager1 manager) {
  super(manager.getWebDriver());
}

 @Override
 public void create(Film film) {
        pages.internalPage.clickAddFilmPage().ensurePageLoaded()
           .setTitleField(film.getTitle())
               .setYearField(film.getYear())
                   .clickSaveButton();
}

 @Override
 public void open(){
         pages.internalPage.ensurePageLoaded()
          .clickfilmOpen();
 }
 
 @Override
 public void delete(){
         pages.internalPage.ensurePageLoaded()
         .clickfilmDelete();
 }

 @Override
 public void notDelete(){
         pages.internalPage.ensurePageLoaded()
         .clickfilmNotDelete();
 }
 @Override
 public List<Film> search(String title) {
   pages.internalPage.clickFilmSearch(title).waitload(3000);
 return null;
}
 
 @Override
 public boolean isCreated(){
       return  !isTextPresent("This field is required");  
 }
 
 @Override
 public boolean isNotCreated(){
   return isTextPresent("This field is required");
 }
 @Override
 public boolean isDeleted(){
       return  isTextPresent("Add movie") &&
                       isTextPresent("Update all");  
 }
   
 @Override
 public boolean isEmptyList() {
         return isTextPresent("No movies");

 }
 
 @Override
 public boolean notEmptyList() {
   return isElementPresentByCSS("div.nocover");  
 }
}


